/**
 * Created with IntelliJ IDEA.
 * User: happyiu
 * Date: 2021-12-03
 * Time: 15:50
 * Description:
 */
public class TestDemo {


    public static void main(String[] args) {
        String str = "hello";
        String str2 = new String("he")+new String("llo");
        System.out.println(str == str2);
        //打印false

    }


    public static void main5(String[] args) {
        String str = "hello";
        String str2 = "he"+"llo";
        String str3 = "he";
        String str4 = str3+"llo";
        System.out.println(str == str4);
        //打印false
    }



    public static void main4(String[] args) {
        String str = "hello";
        String str2 = "hello";
        System.out.println(str == str2);
        //打印true
    }



    public static void main3(String[] args) {
        String str = "hello";
        String str2 = new String("hello");
        System.out.println(str == str2);
    }


    public static void main2(String[] args) {
        String str = "hello";
        String str2 = str;
        System.out.println(str);
        System.out.println(str2);
        System.out.println("================");
        str = "world";
        System.out.println(str);
        System.out.println(str2);
    }


    public static void main1(String[] args) {
        //第一种
        String str = "hello";
        System.out.println(str);
        //第二种
        String str2 = new String("world");
        System.out.println(str2);
        //第三种
        char [] arr = {'a','b','c'};
        String str3 = new String(arr);
        System.out.println(str3);

    }
}
